
from collections import defaultdict
products =   [['iphone',6888],['MacPro',14800],['小米6',2499],['Coffee',31],['Book',60],['Nike',699]]

products_dict ={}
print('-'*6,'商品列表','-'*6)

for _product,_price in products:
    print(_product,_price,sep='\t')
    if _product.isalpha():
        _product = _product.lower()
    products_dict[_product] = _price

shopping_dict = defaultdict(int)
while True:

    product = input('please choose your product:   ').strip()
    if product == 'q':
        if len(shopping_dict) == 0:
            print('you choose nothing')
            break
        print('-'*6,'购物列表','-'*6)
        total_price = 0

        for n,q in shopping_dict.items():
            price = products_dict[n]*q
            print('name:{}  quantity:{}  --> price:{}'.format(n,q,price))
            total_price += price
        print('totoal price is {}'.format(total_price))
        print('welcome back')
        break
    if product.isalpha():
        if product.lower() in products_dict:
            product = product.lower()
            print('ok please choose again')
            shopping_dict[product] += 1
        else:

            print('not in list !!!  input error --> please enter again')

    else:
        if product in products_dict:
            print('ok please choose again')
            shopping_dict[product] += 1
        else:
            print('not in list !!!  input error --> please enter again')



# 写的很细，大小写都考虑到了。唯一不足的是，没有退出的提示